﻿<!DOCTYPE HTML>
<html>

<head>
    <title></title>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__css/auth_control.css">
    <style>
    </style>
</head>

<body>
<include file="header"/>
<include file="aside"/>
    <!--<nav class="breadcrumb">-->
        <!--<i class="Hui-iconfont">&#xe67f;</i>权限列表-->
        <!--<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);"-->
            <!--title="刷新">-->
            <!--<i class="Hui-iconfont">&#xe68f;</i>-->
        <!--</a>-->
    <!--</nav>-->
    <div class="page-container auth_control Hui-article-box">
        <div class="text-c box_a">
            <div class="add-box">
                <button  class="btn btn-success radius ml-20" onclick="addInfos()">
                    <i class="Hui-iconfont"></i>新建授权人
                </button>
                <!-- <button class="buta" onClick="addInfos()">新增</button> -->
            </div>
            <!--<div class="search-box">-->
                <!--<input type="text" name="" placeholder="请输入文字" style="width:150px" class="input-text">-->
                <!--<button name="" class="btn btn-success" type="submit">-->
                    <!--<i class="Hui-iconfont">&#xe665;</i> 搜索</button>-->
            <!--</div>-->
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <span class="l">
                权限列表
            </span>
            <span class="r">共有数据：
                <strong>{$total}</strong> 条</span>
        </div>
        <table class="table table-border table-bordered table-bg table-hover table-sort auth_table">
            <thead>
                <tr class="text-c">
                    <th>序号</th>
                    <th>姓名</th>
                    <th>联系方式</th>
                    <th>创建时间</th>
                    <th class="del">操作</th>
                </tr>
            </thead>

            <if condition="!empty( $data )">
                <volist name="data" id="list" key="k">
                    <tbody>
                        <tr class="text-c">
                            <td>{$k}</td>
                            <td>{$list.userName}</td>
                            <td>{$list.phoneNumber}</td>
                            <td>{$list.createTime}</td>
                            <td class="del">
                                <i class="Hui-iconfont delete" onClick="deleteInfos(this,'{$list.id}')">&#xe6a6;</i>
                            </td>
                        </tr>
                    </tbody>
                </volist>
                <else/>
                <tbody>
                <tr class="text-c">
                    <td colspan="5">暂时无数据</td>
                </tr>
                </tbody>
            </if>
        </table>
        {$page}
    </div>

    <div id="addInfos" class="modal fade auth_control_pop" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content radius">
                <div class="modal-header">
                    <h3 class="modal-title">新增列表</h3>
                    <a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
                </div>
                <div class="modal-body">
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-3 text-r">姓名：</label>
                        <div class="formControls col-xs-4 col-sm-6">
                            <input type="text" class="input-text radius userName" autocomplete="off" name="userName" placeholder="请输入姓名">
                        </div>
                    </div>
                    <div class="row cl mt-20">
                        <label class="form-label col-xs-4 col-sm-3 text-r">联系方式：</label>
                        <div class="formControls col-xs-4 col-sm-6">
                            <input type="text" class="input-text radius phone" autocomplete="off" name="iphone" placeholder="请输入手机号码">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-primary auth_submit" onclick="sureAddPow()">确定</button>
                    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
                </div>
            </div>
        </div>
    </div>


    <script type="text/javascript" src="__PUBLIC__/Admin/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Admin/lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Admin/static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Admin/static/h-ui.admin/js/H-ui.admin.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Admin/lib/laypage/1.2/laypage.js"></script>

    <script>
        $(function () {
            //号码格式检测
            $('.phone').on("input propertychange", function () {
                var _val = $(this).val();
                var pattern = /^1[34578]\d{9}$/;
                if (_val == '') {
                    $('.codeBtn').removeClass('active');
                } else if (!pattern.test(_val)) {
                    $('.codeBtn').removeClass('active');
                } else {
                    $('.codeBtn').addClass('active');
                    $('.phone-box .tips-layer').hide();
                }
            })
            $('.auth_submit').on('click', function () {
                /**
                 * 提交信息
                 */
                var name = $('.userName').val();
                var phone = $('.phone').val();
                var pattern = /^1[34578]\d{9}$/;
                if (name == '') {
                    $.Huimodalalert('请输入姓名', 2000)
                }   else if (name.length>5) {
                    $.Huimodalalert('姓名在5个字内', 2000);
                } else if (phone == '') {
                    $.Huimodalalert('请输入手机号码', 2000)
                } else if (!pattern.test(phone)) {
                    $.Huimodalalert('手机号码填写有误', 2000)
                } else {
                    // $.Huimodalalert('添加成功', 2000)
                    // $("#addInfos").modal("hide")
                    // var infos = '<tr class="text-c">' +
                    //     '            <td>1</td>' +
                    //     '            <td>' + name + '</td>' +
                    //     '            <td>' + phone + '</td>' +
                    //     '            <td>2018-02-15</td>' +
                    //     '            <td class="del">' +
                    //     '                <i class="Hui-iconfont delete" onClick="deleteInfos(this)">&#xe6a6;</i>' +
                    //     '            </td>' +
                    //     '        </tr>'
                    // $('.auth_table tbody').append(infos)

                    var userName=$("input:text[name='userName']").val();
                    var iphone=$("input:text[name='iphone']").val();
                    alert(userName);
                    alert(iphone);

                    $.ajax({
                        type: "post",
                        url: "{:U('Admin/sureAddPow')}",
                        data: {"userName": userName, "iphone":iphone},
                        success:function (result) {
                            if ( result == 10 ) {
                                layer.msg('操作成功', {icon: 1});
                                window.location.reload();
                            } else {
                                layer.msg('操作失败', {icon: 5});
                                return false;

                            }
                        }
                    })



                }
            })
        })

        /**
         * 管理弹出层
         */
        function managelist() {
            $("#managelist").modal("show")
        }

        /**
         * 新增
         */

        function addInfos() {
            $("#addInfos").modal("show")
        }


        /**
         * 删除
         */
        function deleteInfos(obj,id) {
            var id=id;
            var objParent = $(obj).parents('tr')
            //询问框
            layer.confirm('温馨提示？', {
                btn: ['确定', '取消'], //按钮
                shade: false //显示遮罩
            }, function () {
                $.ajax({
                    type: "post",
                    url: "{:U('Admin/authDel')}",
                    data: {"id": id},
                    success:function (result) {
                        if ( result == 10 ) {
                            layer.msg('操作成功', {icon: 1});
                            window.location.reload()
                        } else {
                            layer.open({content:'操作失败',time: 2});
                            return false;

                        }
                    }
                })
                objParent.remove()
            }, function () {
                layer.close()
            });
        }



        /**
         * 重命添加
         */
        function sureAddPow() {


        }





    </script>

</body>

</html>